package com.grass.p019lv.game.view;

import android.app.Activity;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.grass.p019lv.game.DecimalDigitsInputFilter;

/* renamed from: com.grass.lv.game.view.GameDialogUtils */
public class GameDialogUtils {
    private static GameDialogUtils mGameDialogUtils;
    private boolean clickLimit = true;
    private long lastClickTime;

    /* renamed from: com.grass.lv.game.view.GameDialogUtils$OnConfirmListener */
    public interface OnConfirmListener {
        void onConfirm();
    }

    /* renamed from: com.grass.lv.game.view.GameDialogUtils$OnSelectConfirmListener */
    public interface OnSelectConfirmListener {
        void onConfirmSelect(String str, int i);
    }

    public static GameDialogUtils getInstance() {
        if (mGameDialogUtils == null) {
            mGameDialogUtils = new GameDialogUtils();
        }
        return mGameDialogUtils;
    }

    public void createTransferDialog(Activity activity, final double d, final double d2, final OnSelectConfirmListener onSelectConfirmListener) {
        final CustomDialog customDialog = new CustomDialog(activity, R.style.transfer_dialog_style, R.layout.dialog_transfer, false);
        customDialog.setCanceledOnTouchOutside(true);
        customDialog.setCancelable(true);
        if (!activity.isFinishing()) {
            customDialog.show();
            Window window = customDialog.getWindow();
            window.getDecorView().setPadding(0, 0, 0, 0);
            WindowManager.LayoutParams attributes = window.getAttributes();
            attributes.width = -1;
            attributes.height = -2;
            window.setAttributes(attributes);
        }
        final EditText editText = (EditText) customDialog.findViewById(R.id.et_transfer);
        final TextView textView = (TextView) customDialog.findViewById(R.id.tv_transfer_money);
        editText.setFilters(new InputFilter[]{new DecimalDigitsInputFilter(9, 2)});
        editText.addTextChangedListener(new TextWatcher() {
            /* class com.grass.p019lv.game.view.GameDialogUtils.C30441 */

            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            }

            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            }

            public void afterTextChanged(Editable editable) {
                textView.setText(editable.toString());
            }
        });
        final TextView textView2 = (TextView) customDialog.findViewById(R.id.tv_money);
        final TextView textView3 = (TextView) customDialog.findViewById(R.id.tv_game_money);
        final int[] iArr = {1};
        ((ImageView) customDialog.findViewById(R.id.iv_change)).setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.game.view.GameDialogUtils.View$OnClickListenerC30452 */

            public void onClick(View view) {
                int[] iArr = iArr;
                if (iArr[0] == 1) {
                    iArr[0] = 2;
                    textView3.setText("钱包余额");
                    textView2.setText("游戏余额");
                    return;
                }
                iArr[0] = 1;
                textView3.setText("游戏余额");
                textView2.setText("钱包余额");
            }
        });
        customDialog.findViewById(R.id.tv_submit).setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.game.view.GameDialogUtils.View$OnClickListenerC30463 */

            public void onClick(View view) {
                String trim = editText.getText().toString().trim();
                if (TextUtils.isEmpty(trim)) {
                    ToastUtils.getInstance().showWeak("请输入划转金额");
                } else if (Double.valueOf(trim).doubleValue() < 1.0d) {
                    ToastUtils.getInstance().showWeak("划转金额不能小于1元");
                } else {
                    if (iArr[0] == 1) {
                        if (Double.valueOf(trim).doubleValue() > d) {
                            ToastUtils.getInstance().showWeak("钱包余额不足");
                            return;
                        }
                    } else if (Double.valueOf(trim).doubleValue() > d2) {
                        ToastUtils.getInstance().showWeak("游戏钱包余额不足");
                        return;
                    }
                    onSelectConfirmListener.onConfirmSelect(trim, iArr[0]);
                    customDialog.dismiss();
                }
            }
        });
        customDialog.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.game.view.GameDialogUtils.View$OnClickListenerC30474 */

            public void onClick(View view) {
                customDialog.dismiss();
            }
        });
    }

    public void createGameWebViewDialog(Activity activity, final OnConfirmListener onConfirmListener) {
        final CustomDialog customDialog = new CustomDialog(activity, R.style.transfer_dialog_style, R.layout.dialog_webview, false);
        customDialog.setCanceledOnTouchOutside(true);
        customDialog.setCancelable(true);
        if (!activity.isFinishing()) {
            customDialog.show();
            Window window = customDialog.getWindow();
            window.getDecorView().setPadding(0, 0, 0, 0);
            WindowManager.LayoutParams attributes = window.getAttributes();
            attributes.width = -1;
            attributes.height = -2;
        }
        customDialog.findViewById(R.id.tv_submit).setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.game.view.GameDialogUtils.View$OnClickListenerC30485 */

            public void onClick(View view) {
                onConfirmListener.onConfirm();
                customDialog.dismiss();
            }
        });
        customDialog.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
            /* class com.grass.p019lv.game.view.GameDialogUtils.View$OnClickListenerC30496 */

            public void onClick(View view) {
                customDialog.dismiss();
            }
        });
    }

    /* access modifiers changed from: protected */
    public boolean isOnClick() {
        long currentTimeMillis = System.currentTimeMillis();
        long j = currentTimeMillis - this.lastClickTime;
        if (j > 1000) {
            this.lastClickTime = currentTimeMillis;
        }
        return !this.clickLimit ? j < 0 : j <= 1000;
    }
}
